import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'

// 导入全局样式表
import './assets/css/global.css'
import './plugins/element.js'
import './assets/font/iconfont.css'

// 忽略警告问题
Vue.config.productionTip = false

axios.interceptors.request.use(config => {
  // console.log(config)
  config.headers.Authorization  = window.sessionStorage.getItem('token')
  // 在最后必须 return config
  return config
})


// 拦截响应
axios.interceptors.response.use(res=>{
  if(res.data.code === 501){
      router.replace('/login');
      localStorage.removeItem('token')
  }
  return res
})


Vue.prototype.$axios = axios

// 请求根路径
axios.defaults.baseURL = "http://127.0.0.1:8001/student";
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
